//
//  XKVisitorTableViewController.swift
//  XK2WeiBo
//
//  Created by mac on 16/7/5.
//  Copyright © 2016年 陈肖坤. All rights reserved.
//

import UIKit

class XKVisitorTableViewController: UITableViewController {

    //标识用户是否登录
    let isLogin: Bool = false
    
    //访客视图对象
    var visitorView: XKVisitoView?
    
    override func loadView() {
        
        if isLogin {
            //代表登录
            super.loadView()
        
        }else {
            //代表用户没有登录
            setupVisitorView()
        }
    }
    
    //MARK: 设置访客视图
    fileprivate func setupVisitorView() {
        setupNav()
        visitorView = XKVisitoView()
        visitorView?.closure = {[weak self] in
            self?.loginClick()
        }
        view = visitorView
    }
    
    //MARK: 设置导航栏
    fileprivate func setupNav() {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.plain, target: self, action: #selector(XKVisitorTableViewController.loginClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.plain, target: self, action: #selector(XKVisitorTableViewController.loginClick))
    
    }
    
    //MARK: 监听点击事件方法
    @objc fileprivate func loginClick() {
        //弹出控制器
        let oauthVC = XKOAuthViewController()
        let navVC = UINavigationController(rootViewController:oauthVC)
        
        present(navVC, animated: true, completion: nil)
        
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
       
    }
    
    
    
    
}
